﻿<Window x:Class="SessionHunter.Views.ChangeDatabaseConnectionView"
		xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
		xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
		xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
		xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
		xmlns:ignore="http://www.ignore.com"
		xmlns:validators="clr-namespace:SessionHunter.Business.Validators"
		mc:Ignorable="d ignore"
		Title="Session Hunter - Database Connection"
		WindowStyle="None"
		ShowInTaskbar="False"
		ResizeMode="NoResize"
		Height="394"
		Width="448"
		DataContext="{Binding ChangeDatabaseConnection, Source={StaticResource Locator}}" 
		Background="White" BorderThickness="2" BorderBrush="Black">

	<Window.Resources>
		<ResourceDictionary>
			<ResourceDictionary.MergedDictionaries>
				<ResourceDictionary Source="/Styles/Controls.xaml"/>
				<ResourceDictionary Source="/Styles/Validation.xaml"/>
			</ResourceDictionary.MergedDictionaries>
		</ResourceDictionary>
	</Window.Resources>

	<StackPanel>
		<validators:ErrorProvider ValidationTag="Validate">
			<Grid>
				<Grid.RowDefinitions>
					<RowDefinition Height="15"/>
					<RowDefinition Height="30"/>
					<RowDefinition Height="30"/>
					<RowDefinition Height="40"/>
					<RowDefinition Height="40"/>
					<RowDefinition Height="40"/>
					<RowDefinition Height="40"/>
				</Grid.RowDefinitions>
				<Grid.ColumnDefinitions>
					<ColumnDefinition Width="25" />
					<ColumnDefinition Width="100"/>
					<ColumnDefinition Width="300"/>
					<ColumnDefinition Width="25" />
				</Grid.ColumnDefinitions>
				<RadioButton x:Name="rbIntegratedAuthentication" GroupName="rbgAuthentication" IsChecked="{Binding Path=Select_IntegratedAuthentication}" Grid.Column="1" Grid.Row="1" Grid.ColumnSpan="2" Content="{Binding Source={StaticResource LocStrings}, Path=Connection_IntegratedAuthentication}" VerticalAlignment="Center" />
				<RadioButton x:Name="rbSQLAuthentication" GroupName="rbgAuthentication" IsChecked="{Binding Path=Select_SQLAuthentication}" Grid.Column="1" Grid.Row="2" Grid.ColumnSpan="2" Content="{Binding Source={StaticResource LocStrings}, Path=Connection_SQLAuthentication}" VerticalAlignment="Center" />
				<TextBlock Grid.Column="1" Grid.Row="3" Text="{Binding Source={StaticResource LocStrings}, Path=Connection_DataSource}" VerticalAlignment="Center"/>
				<TextBox x:Name="txtDataSource" Text="{Binding Path=DataSource, UpdateSourceTrigger=PropertyChanged}" Grid.Column="2" Grid.Row="3" VerticalAlignment="Center" Tag="Validate" />
				<TextBlock Grid.Column="1" Grid.Row="4" Text="{Binding Source={StaticResource LocStrings}, Path=Connection_Database}" VerticalAlignment="Center"/>
				<TextBox x:Name="txtDatabase" Text="{Binding Path=Database, UpdateSourceTrigger=PropertyChanged}" Grid.Column="2" Grid.Row="4" VerticalAlignment="Center" Tag="Validate"/>
				<TextBlock Grid.Column="1" Grid.Row="5" Text="{Binding Source={StaticResource LocStrings}, Path=Connection_UserName}" VerticalAlignment="Center" />
				<TextBox x:Name="txtUserName" Text="{Binding Path=Username, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" IsEnabled="{Binding ElementName=rbSQLAuthentication, Path=IsChecked}" Grid.Column="2" Grid.Row="5" VerticalAlignment="Center" Tag="Validate" />
				<TextBlock Grid.Column="1" Grid.Row="6" Text="{Binding Source={StaticResource LocStrings}, Path=Connection_Password}" VerticalAlignment="Center" />
				<PasswordBox x:Name="txtPassword" Grid.Column="2" IsEnabled="{Binding ElementName=rbSQLAuthentication, Path=IsChecked}" Grid.Row="6" VerticalAlignment="Center" PasswordChar="•"/>
			</Grid>
		</validators:ErrorProvider>
		<Grid>
			<Grid.RowDefinitions>
				<RowDefinition Height="60"/>
				<RowDefinition Height="60"/>
			</Grid.RowDefinitions>
			<Grid.ColumnDefinitions>
				<ColumnDefinition Width="*"/>
				<ColumnDefinition Width="*"/>
			</Grid.ColumnDefinitions>
			<CheckBox x:Name="cbEncryptConnection" Grid.Row="0" Grid.Column="1" IsChecked="{Binding Path=EncryptConnection}" Content="{Binding Source={StaticResource LocStrings}, Path=Connection_EncryptConnection}" VerticalAlignment="Center" Grid.ColumnSpan="2" Margin="45,0,0,0" />
			<Button x:Name="btnTestConnection" Grid.Column="0" Grid.Row="0" Command="{Binding Command_TestConnection}" IsEnabled="{Binding IsSaveEnabled}" Style="{DynamicResource RoundedButton}" Width="130" Height="40" Content="{Binding Source={StaticResource LocStrings}, Path=Button_TestConnection}" CommandParameter="{Binding ElementName=txtPassword}"  BorderBrush="{StaticResource BlueButton}" VerticalAlignment="Center" HorizontalAlignment="Center"></Button>
			<Button x:Name="btnSave" Grid.Column="0" Grid.Row="1" Command="{Binding Command_Save}" IsEnabled="{Binding IsSaveEnabled}" Style="{DynamicResource RoundedButton}" Width="130" Height="40" Content="{Binding Source={StaticResource LocStrings}, Path=Button_Save}" CommandParameter="{Binding ElementName=txtPassword}" BorderBrush="{StaticResource BlueButton}" VerticalAlignment="Center" HorizontalAlignment="Center" />
			<Button x:Name="btnCancel" Grid.Column="1" Grid.Row="1" Command="{Binding Command_CancelOrExit}" Style="{DynamicResource RoundedButton}" Width="130" Height="40" Content="{Binding Source={StaticResource LocStrings}, Path=Button_Cancel}"  BorderBrush="{StaticResource BlueButton}" VerticalAlignment="Center" HorizontalAlignment="Center"></Button>
		</Grid>
	</StackPanel>
</Window>
